import helper from 'tipsi-appium-helper'

const { driver, idFromAccessId } = helper
const timeout = 60000

export default async function openTestSuite(name) {
  const drawerButton = idFromAccessId('toggleDrawerButton')
  const menuButton = idFromAccessId(name)
  try {

    let elem = await driver.$(drawerButton)
    await elem.waitForDisplayed(timeout)
    await elem.click()

    elem = await driver.$(menuButton)
    await elem.waitForDisplayed(timeout)
    await elem.click()

  } catch (e) {
    console.log("Failed to openTestSuite", e)
    console.log(await driver.getPageSource())
    throw e
  }
}
